package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.pojo.Ability;
import com.ant.storage.service.IAbilityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author melon
 * @since 2022-11-30
 */
@Api(tags = "功能接口")
@RestController
@RequestMapping("/ability")
public class AbilityController {

    @Autowired
    private IAbilityService abilityService;

    @ApiOperation(value = "添加/修改功能")
    @PostMapping("/addAbility")
    public ResultVo addAbility(@RequestBody Ability ability) {
        if(ability.getId()==null) {
            abilityService.save(ability);
        }   else {
            abilityService.updateById(ability);
        }

        return ResultVo.success("操作成功");
    }

    @ApiOperation(value = "查询功能")
    @GetMapping("/getAbility")
    public ResultVo getAbility() {
        return ResultVo.success("查询成功", abilityService.list());
    }

}
